import os

def check_missing_prefab(folder_path, extensions):
    # 将后缀名转换为集合，以便更快地进行匹配
    extensions_set = set(extensions)
    
    # 创建一个字典来保存每种后缀名的文件
    files_by_extension = {ext: {} for ext in extensions_set}
    prefab_files = set()
    
    # 遍历文件夹中的所有文件
    for root, dirs, files in os.walk(folder_path):
        for file_name in files:
            file_base_name, file_ext = os.path.splitext(file_name)
            file_path = os.path.join(root, file_name)
            if file_ext == '.prefab':
                prefab_files.add(file_base_name)
            elif file_ext in extensions_set:
                files_by_extension[file_ext][file_base_name] = file_path
    
    # 检查缺失.prefab文件
    missing_prefab_files = set()
    for ext in extensions_set:
        missing_prefab_files.update(set(files_by_extension[ext].keys()) - prefab_files)
    
    # 打印缺失.prefab文件的完整路径
    for missing_prefab_file in missing_prefab_files:
        for ext, file_path in files_by_extension.items():
            if missing_prefab_file in file_path:
                print(f"{file_path[missing_prefab_file]}没有prefab文件")

# 文件夹路径
folder_path = 'C:/WorkPlace/SVN_WorkSpace/SVN_AutoCommitTest'

# 要检查的后缀名
extensions = ['.png', '.txt', '.ktx']

# 检查指定后缀名的文件
check_missing_prefab(folder_path, extensions)
